package st.mark.quadtris;

public class Piece {
    private String name;
    Tuple [][] rotationMatrice;
    int currentRotation;
 
    public Piece(String name, Tuple [][] rotationMatrice) {
        this.name = name;
 
        currentRotation = 0;
 
        this.rotationMatrice = rotationMatrice;
    }
    
    public int getColor(){
    	switch(name.charAt(0)){
	        case 't':  return 0;
	        case 'z':  return 1;
	        case 's':  return 2;
	        case 'o':  return 3;
	        case 'i':  return 4;
	        case 'l':  return 5;
	        case 'j':  return 6;
    	}
    	
    	return 0;
    }
    
    public Tuple getPosOfBlock( int blockNumber )
    {
        return rotationMatrice[currentRotation][blockNumber];
    }
 
    public void rotateRight()
    {
    	currentRotation++;
    	if(currentRotation >= 4)
        	currentRotation = 0;
    }
 
    public void rotateLeft()
    {
    	currentRotation--;
    	if(currentRotation < 0)
        	currentRotation = 3;
    }
    
    public void resetRotation(){
    	currentRotation = 0;
    }
 
    public static class Tuple{
        public int x;
        public int y;
        public Tuple(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }
}
